package com.lestv.util;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPrefHelper {
	/**
	 * SharedPreferences的名字
	 */
	private static SharedPrefHelper sharedPrefHelper = null;
	private static SharedPreferences sharedPreferences;
	
	/**
	 * 经度
	 */
	private static final String LONGITUDE = "LONGITUDE";
	/**
	 * 纬度
	 */
	private static final String LATITUDE = "LATITUDE";
	public void setLongitude(String longitude){
		sharedPreferences.edit().putString(LONGITUDE, longitude).commit();
	}
	public void setLatitude(String latitude){
		sharedPreferences.edit().putString(LATITUDE, latitude).commit();
	}
	public String getLongitude(){
		return sharedPreferences.getString(LONGITUDE, "");
	}
	
	public String getLatitude(){
		return sharedPreferences.getString(LATITUDE, "");
	}
	/**
	 * 自动登陆
	 * @param context
	 * @return
	 */
	public static synchronized SharedPrefHelper getInstance(Context context) {
		if (null == sharedPrefHelper) {
			sharedPrefHelper = new SharedPrefHelper();
			//ilestvAPP 是不是随便起的，到后面就数据替换了
			sharedPreferences = context.getSharedPreferences("ilestvAPP",
					Context.MODE_PRIVATE);
		}
		return sharedPrefHelper;
	}
	/**
	 *登陆之后存储
	 * @param isFirst
	 */
	public void setFirstLogin(boolean isFirst){
		sharedPreferences.edit().putBoolean("isFirst", isFirst).commit();

	}
	/**
	 * 第一次打开APP
	 * @return
	 */
	public boolean isFirstLogin(){
		return sharedPreferences.getBoolean("isFirst", true);
	}
	/**
	 * 获取用户之前输入的电话号码
	 */
	public String getUserName() {
		return sharedPreferences.getString("userName", "");
	}
	public void setUserName (String userName){
		sharedPreferences.edit().putString("userName", userName).commit();
	}
	public String getUserPass() {
		return sharedPreferences.getString("userPass", "");
	}
	public void setUserPass (String userPass){
		sharedPreferences.edit().putString("userPass", userPass).commit();
	}
}
